package com.jctrip.hotel.source.client;

import com.jctrip.hotel.source.model.wehotel.resq.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jctrip.hotel.source.model.wehotel.req.GetBrandListResult;
import com.jctrip.hotel.source.model.wehotel.req.GetHotelIdsResult;
import com.jctrip.hotel.source.model.wehotel.req.GetHotelImageResult;
import com.jctrip.hotel.source.model.wehotel.req.GetHotelRoomStatusResult;
import com.jctrip.hotel.source.model.wehotel.req.GetHotelRoomTypeResult;
import com.jctrip.hotel.source.model.wehotel.req.HotelInfoData;
import com.jctrip.hotel.source.model.wehotel.req.OrderData;
import com.jctrip.hotel.source.model.wehotel.req.WeHotelResult;

/**
 * @Author henry
 * @Date 2023/5/24 22:14
 * @Description
 */
@FeignClient(name = "WeHotelClient", url = "${feign.url.wehotel}")
@RequestMapping(headers = {"Content-Type=application/json", "accept=application/json"})
public interface WeHotelClient {

    /**
     * 品牌列表信息查询
     */
    @PostMapping("/brand/getBrandList")
    WeHotelResult<GetBrandListResult> getBrandList(
            @RequestHeader("fizz-appid") String appId,
            @RequestHeader("timestamp") Long timestamp,
            @RequestHeader("sign") String sign,
            @RequestBody GetBrandList getBrandList
    );

    /**
     * 酒店编号信息
     */
    @PostMapping("/hotel/getHotelIds")
    WeHotelResult<GetHotelIdsResult> getHotelIds(
            @RequestHeader("fizz-appid") String appId,
            @RequestHeader("timestamp") Long timestamp,
            @RequestHeader("sign") String sign,
            @RequestBody GetHotelIds getHotelIds
    );

    /**
     * 酒店详细信息
     * 酒店是否售卖，必须满足status=1开业并且bookFlag=1可预订
     */
    @PostMapping("/hotel/getHotelInfo")
    WeHotelResult<HotelInfoData> getHotelInfo(
            @RequestHeader("fizz-appid") String appId,
            @RequestHeader("timestamp") Long timestamp,
            @RequestHeader("sign") String sign,
            @RequestBody GetHotelInfo getHotelInfo
    );

    /**
     * 酒店相册图片
     */
    @PostMapping("/hotel/getHotelImage")
    WeHotelResult<GetHotelImageResult> getHotelImage(
            @RequestHeader("fizz-appid") String appId,
            @RequestHeader("timestamp") Long timestamp,
            @RequestHeader("sign") String sign,
            @RequestBody GetHotelImage getHotelImage
    );

    /**
     * 酒店房型
     */
    @PostMapping("/hotel/getHotelRoomType")
    WeHotelResult<GetHotelRoomTypeResult> getHotelRoomType(
            @RequestHeader("fizz-appid") String appId,
            @RequestHeader("timestamp") Long timestamp,
            @RequestHeader("sign") String sign,
            @RequestBody GetHotelRoomType getHotelRoomType
    );

    /**
     * 酒店房态
     * 房态接口的时效性是针对请求方的请求营业日和请求查询天数来计算，如果预订日期超出了这段时间该协议价是无效。例如预订请求时间为6月3-6月8号的，房态数据只符合这5天，预订是6月9
     * 号是不一定符合能沿用原来的价格了（假若要根据对应的价格协议的有效时间是否永久和时间区间进行判断）
     * 解析取消规则顺序："newCancelPenaltyList" 》 "cancelPenaltyList" 》"freeCancelTime"
     */
    @PostMapping("/hotel/getHotelRoomStatus")
    WeHotelResult<GetHotelRoomStatusResult> getHotelRoomStatus(
            @RequestHeader("fizz-appid") String appId,
            @RequestHeader("timestamp") Long timestamp,
            @RequestHeader("sign") String sign,
            @RequestBody GetHotelRoomStatus getHotelRoomStatus
    );

    /**
     * 酒店实时房态
     * 下单时候需要验证房源和房价
     */
    @PostMapping("/hotel/getHotelRealRoomStatus")
    WeHotelResult<GetHotelRoomStatusResult> getHotelRealRoomStatus(
            @RequestHeader("fizz-appid") String appId,
            @RequestHeader("timestamp") Long timestamp,
            @RequestHeader("sign") String sign,
            @RequestBody GetHotelRealRoomStatus getHotelRealRoomStatus
    );


    /**
     * 下单预定
     */
    @PostMapping("/booking/postOrder")
    WeHotelResult<OrderData> postOrder(
            @RequestHeader("fizz-appid") String appId,
            @RequestHeader("timestamp") Long timestamp,
            @RequestHeader("sign") String sign,
            @RequestBody PostOrder postOrder
    );

    /**
     * 取消订单
     */
    @PostMapping("/booking/cancelOrder")
    WeHotelResult<Void> cancelOrder(
            @RequestHeader("fizz-appid") String appId,
            @RequestHeader("timestamp") Long timestamp,
            @RequestHeader("sign") String sign,
            @RequestBody CancelOrder cancelOrder
    );

    /**
     * 查看订单,返回部分信息，订单状态
     */
    @PostMapping("/booking/queryOrder")
    WeHotelResult<QueryOrderResp> queryOrder(
            @RequestHeader("fizz-appid") String appId,
            @RequestHeader("timestamp") Long timestamp,
            @RequestHeader("sign") String sign,
            @RequestBody QueryOrder queryOrder
    );
}
